package com.code.monitor.constants;

/**
 * @author ggh
 * @date 2023/4/24
 */
public enum ResourceType {
    TEXT("", "text/plain; charset=utf-8"),
    HTML("html", "text/html; charset=utf-8"),
    JAVASCRIPT("js", "text/javascript; charset=utf-8"),
    CSS("css", "text/css"),
    IMG("png", "image/png"),
    ICON("ico", "image/x-icon"),
    SVG("svg", "image/svg+xml");

    private String suffix;

    private String contentType;

    ResourceType(String suffix, String contentType) {
        this.suffix = suffix;
        this.contentType = contentType;
    }

    public String getContentType() {
        return contentType;
    }

    public String getSuffix() {
        return suffix;
    }

    public static String contentType(String suffix) {
        for (ResourceType resourceType : values()) {
            if (resourceType.getSuffix().equalsIgnoreCase(suffix)) {
                return resourceType.getContentType();
            }
        }
        return TEXT.getContentType();
    }
}
